package com.fzb.forum4j.incp;

import org.apache.struts2.interceptor.ActionMappingParametersInteceptor;
import org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor;

import com.fzb.forum4j.controller.CommonsAction;
import com.fzb.forum4j.po.QueryMode;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;

public class AdminJsonDataInterceptor extends AnnotationValidationInterceptor{

 
	@SuppressWarnings("rawtypes")
	@Override
	public String intercept(ActionInvocation invocation) throws Exception {
		
		doBeforeInvocation(invocation);
		System.out.println(((CommonsAction)invocation.getAction()).getFieldErrors().isEmpty());
		if(!((CommonsAction)invocation.getAction()).getFieldErrors().isEmpty()){
			return invocation.getProxy().getActionName();
		}
		System.out.println(((QueryMode)invocation.getStack().getRoot().get(0)).getRows());
		invocation.invokeActionOnly();
		invocation.getStack().push(((CommonsAction)invocation.getAction()).getData());
		return "json";
	}

 
}
